package net.csdra.libraryborrowing.service.user;

import net.csdra.libraryborrowing.domain.user.User;
import net.csdra.libraryborrowing.domain.user.UserAuthoriry;
import net.csdra.libraryborrowing.service.PageEntity;
import org.springframework.data.domain.Page;
import org.springframework.security.access.prepost.PreAuthorize;

import java.nio.file.AccessDeniedException;
import java.util.List;

/**
 * Created by msf on 2017/10/11.
 */
@PreAuthorize("hasRole('" + UserAuthoriry.USER_AUTHORIRY_MANGE + "')")
public interface UserManageService {
    public User createUser(CreateUser createUser) throws AccessDeniedException;

    public User updateUser(UpdateUser updateUser) throws AccessDeniedException;

    public User getUserById(GetUserById getUserById);

    /**
     * 根据key模糊查询
     *
     * @param getUserLikeUserName
     * @return
     */
    public List<User> getUserLikeUserName(GetUserLikeUserName getUserLikeUserName);

    public Page<User> getUserPage(GetUserPage getUserPage);

    public Page<User> getUserByAuthoryPage(GetUserByAuthoryPage getUserByAuthoryPage);

    class CreateUser {
        String userName;
        CharSequence password;
        String nikiName;
        String cover;
        String customize;

        public String getCustomize() {
            return customize;
        }

        public void setCustomize(String customize) {
            this.customize = customize;
        }

        public String getUserName() {
            return userName;
        }

        public void setUserName(String userName) {
            this.userName = userName;
        }

        public CharSequence getPassword() {
            return password;
        }

        public void setPassword(CharSequence password) {
            this.password = password;
        }

        public String getNikiName() {
            return nikiName;
        }

        public void setNikiName(String nikiName) {
            this.nikiName = nikiName;
        }

        public String getCover() {
            return cover;
        }

        public void setCover(String cover) {
            this.cover = cover;
        }
    }

    class UpdateUser extends CreateUser {
        String id;
        boolean deleted;
        boolean enabled;
        Long order;
        List<String> authoritys;

        public List<String> getAuthoritys() {
            return authoritys;
        }

        public void setAuthoritys(List<String> authoritys) {
            this.authoritys = authoritys;
        }

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public boolean isDeleted() {
            return deleted;
        }

        public void setDeleted(boolean deleted) {
            this.deleted = deleted;
        }

        public boolean isEnabled() {
            return enabled;
        }

        public void setEnabled(boolean enabled) {
            this.enabled = enabled;
        }

        public Long getOrder() {
            return order;
        }

        public void setOrder(Long order) {
            this.order = order;
        }
    }

    class GetUserById {
        String id;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }
    }

    class GetUserPage extends PageEntity {

    }

    class GetUserByAuthoryPage extends GetUserPage {
        List<String> authoritys;

        public List<String> getAuthoritys() {
            return authoritys;
        }

        public void setAuthoritys(List<String> authoritys) {
            this.authoritys = authoritys;
        }
    }

    class GetUserLikeUserName {
        String key;
        //返回条数
        String resultNum;

        public String getResultNum() {
            return resultNum;
        }

        public void setResultNum(String resultNum) {
            this.resultNum = resultNum;
        }

        public String getKey() {
            return key;
        }

        public void setKey(String key) {
            this.key = key;
        }
    }
}
